﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Configuration;

namespace IB_report_stand.Dialog
{
    public partial class dlg_company_settings : DevExpress.XtraEditors.XtraForm
    {
        public dlg_company_settings()
        {
            InitializeComponent();
        }

        private void dlg_company_settings_Load(object sender, EventArgs e)
        {
            txtCompanyName.Text = ConfigurationManager.AppSettings["companyName"];
            txtCompanyAddress.Text = ConfigurationManager.AppSettings["companyAddress"];
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings.Remove("companyName");
            config.AppSettings.Settings.Remove("companyAddress");

            config.AppSettings.Settings.Add("companyName", txtCompanyName.Text);
            config.AppSettings.Settings.Add("companyAddress", txtCompanyAddress.Text);
            config.Save(ConfigurationSaveMode.Modified);

            ConfigurationManager.RefreshSection("appSettings");

            this.Dispose();
        }

    }
}